/**
 * regexListStorer——校验正则
 * validateTypes——自定义校验类型
 */
import validator from "validator";
const regexListStorer = {
  email: [
    { type: "isFilled", message: "请输入邮箱！" },
    { type: "isEmail", message: "请输入正确的Email格式！" }
  ],
  account: [
    { type: "isFilled", message: "请输入账户名！" },
    { type: "isLength", min: 1, max: 30, message: "请不少于1个字符的账户名！" }
  ],
  uname: [
    { type: "isFilled", message: "请输入用户名！" },
    {
      type: "isLength",
      min: 1,
      max: 30,
      message: "请不少于1个字符！用户名/邮箱/已验证的手机号"
    }
  ],
  checkTel: [
    { type: "isFilled", message: "请输入电话号码！" },
    { type: "isTel", message: "请输入正确的电话号码格式！" }
  ],
  emailCode: [{ type: "isFilled", message: "请输入验证码" }],
  upwd: [
    { type: "isFilled", message: "请输入密码！" },
    { type: "isLength", min: 6, max: 20, message: "请输入不少于6位的密码！" }
  ],
  rePwd: [
    { type: "isFilled", message: "请输入确认密码！" },
    { type: "isLength", min: 6, max: 20, message: "请输入不少于6位的密码！" }
  ],
  phone: [
    { type: "isFilled", message: "请输入手机号码！" },
    {
      type: "isMobilePhone",
      options: "zh-CN",
      message: "请输入正确的手机号格式！"
    }
  ],
  default: [{ type: "isFilled", message: "请输入内容" }],
  startTime: [{ type: "isFilled", message: "请选择开始时间" }],
  eduEndTime: [{ type: "isFilled", message: "请选择毕业时间" }],
  school: [{ type: "isFilled", message: "请输入毕业学校" }],
  major: [{ type: "isFilled", message: "请输入专业" }],
  education: [{ type: "isFilled", message: "请选择学历" }],
  endTime: [{ type: "isFilled", message: "请选择结束时间" }],
  company: [{ type: "isFilled", message: "请输入工作单位" }],
  position: [{ type: "isFilled", message: "请输入职务" }],
  reason: [{ type: "isFilled", message: "请输入离职原因" }],
  descReason: [{ type: "isFilled", message: "请输入应聘该岗位原因" }],
  descAdvantage: [{ type: "isFilled", message: "请输入胜任该岗位的要点" }],
  loginName: [{ type: "isFilled", message: "请输入工号" }],
  loginPwd: [
    { type: "isFilled", message: "请输入身份证后六位" },
    { type: "isLength", min: 6, max: 6, message: "密码不足或超出6位!" }
  ],
  //入职资料相关
  realName: [{ type: "isFilled", message: "请输入姓名" }],
  userSex: [{ type: "isFilled", message: "选择性别" }],
  native: [{ type: "isFilled", message: "请输入籍贯" }],
  race: [{ type: "isFilled", message: "请输入民族" }],
  birthday: [{ type: "isFilled", message: "请输入生日" }],
  idCard: [
    { type: "isFilled", message: "请输入身份证！" },
    { type: "isLength", min: 18, max: 18, message: "请输入18位身份证号" }
  ],
  isMarry: [{ type: "isFilled", message: "请选择婚姻状况" }],
  political: [{ type: "isFilled", message: "请选择政治面貌" }],
  highestEduction: [{ type: "isFilled", message: "请选择教育程度" }],
  vision: [{ type: "isFilled", message: "请填写视力" }],
  height: [{ type: "isFilled", message: "请填写身高" }],
  weight: [{ type: "isFilled", message: "请填写体重" }],
  isDisease: [{ type: "isFilled", message: "请填写视力" }],
  entryType: [{ type: "isFilled", message: "请选择入职方式" }],
  isLeaveCertificate: [{ type: "isFilled", message: "请选择离职证明" }],
  specialty: [{ type: "isFilled", message: "请填写个人专长" }],
  joinType: [{ type: "isFilled", message: "请选择入职类别" }],
  joinTime: [{ type: "isFilled", message: "请填写入创维时间" }],
  joinCompanyTime: [{ type: "isFilled", message: "请填写入制造总部时间" }],

  address: [{ type: "isFilled", message: "请填写地址" }],
  postalcode: [
    { type: "isFilled", message: "请填写邮政编码" },
    {
      type: "isLength",
      min: 4,
      max: 10,
      message: "请输入长度10位以内的邮政编码"
    }
  ],
  emergencyContact: [{ type: "isFilled", message: "请填写紧急联系人" }],
  emergencyPhone: [{ type: "isFilled", message: "请填写紧急联系人电话" }],
  emergencyMember: [{ type: "isFilled", message: "请填写紧急联系人关系" }],

  memberFamilyName1: [{ type: "isFilled", message: "请填写家庭成员1姓名" }],
  memberFamilyMember1: [{ type: "isFilled", message: "请填写家庭成员1关系" }],
  memberFamilyPhone1: [{ type: "isFilled", message: "请填写家庭成员1电话" }],
  memberFamilyAddress1: [{ type: "isFilled", message: "请填写家庭成员1地址" }],
  memberFamilyWork1: [
    { type: "isFilled", message: "请填写家庭成员1单位及职务" }
  ],
  memberFamilyName2: [{ type: "isFilled", message: "请填写家庭成员2姓名" }],
  memberFamilyMember2: [{ type: "isFilled", message: "请填写家庭成员2关系" }],
  memberFamilyPhone2: [{ type: "isFilled", message: "请填写家庭成员2电话" }],
  memberFamilyAddress2: [{ type: "isFilled", message: "请填写家庭成员2地址" }],
  memberFamilyWork2: [
    { type: "isFilled", message: "请填写家庭成员2单位及职务" }
  ],

  oldUnit: [{ type: "isFilled", message: "请填写原工作单位" }],
  intermediary: [{ type: "isFilled", message: "请填写中介单位" }],
  recommender: [{ type: "isFilled", message: "请填写推荐人" }],
  recommendMember: [{ type: "isFilled", message: "请填写与推荐人关系" }],
  recommenderPhone: [{ type: "isFilled", message: "请填写推荐人手机号" }],

  eduStartTime: [{ type: "isFilled", message: "请选择入学时间" }],
  // eduEndTime:[
  //     {type:'isFilled',message:'请选择毕业时间'}
  // ],
  eduSchool: [{ type: "isFilled", message: "请填写学校名称" }],
  eduLevel: [{ type: "isFilled", message: "请选择学历" }],
  eduType: [{ type: "isFilled", message: "请选择学历类型" }],
  eduMajor: [{ type: "isFilled", message: "请填写专业" }],

  workStartTime: [{ type: "isFilled", message: "请填写入职时间" }],
  workEndTime: [{ type: "isFilled", message: "请填写离职时间" }],
  workCompany: [{ type: "isFilled", message: "请填写公司名称" }],
  workTitle: [{ type: "isFilled", message: "请填写职务" }],

  roomNum: [{ type: "isFilled", message: "请输入房间号" }],
  repairDetail: [{ type: "isFilled", message: "请输入报修内容" }],
  teamName: [{ type: "isFilled", message: "请输入团队名称" }]
};

const validateTypes = {
  isRequired: {
    type: "isRequired",
    rlt: (value, rule) => {
      return !!validator.toString(value);
    }
  },
  isFilled: {
    type: "isFilled",
    rlt: (value, rule) => {
      return !!validator.toString(value).trim();
    }
  },
  isInt: {
    type: "isInt",
    rlt: (value, rule) => {
      return validator.isInt(value + "", rule.options);
    }
  },
  isLength: {
    type: "isLength",
    rlt: (value, rule) => {
      return validator.isLength(
        value + "",
        rule.options || { min: rule.min, max: rule.max }
      );
    }
  },
  isTel: {
    type: "isTel",
    rlt: (value, rule) => {
      let tempRlt = value.match("/d{3}-d{8}|d{4}-d{7}/");
      if (tempRlt == null) {
        return false;
      }
      return true;
    }
  }
};
export { validateTypes as vTypes, regexListStorer as regexList };
